<!DOCTYPE html>
<html lang="en">
<head>
    <#import "../common/common.macro.ftl" as netCommon>
	<@netCommon.commonStyle />

</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <!-- header -->
	<@netCommon.commonHeader />
    <!-- left -->
	<@netCommon.commonLeft "app" "appSearch" />

    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">

            <!-- SELECT2 EXAMPLE -->
            <div class="box box-default">
                <div class="box-header with-border">
                    <h3 class="box-title">应用查询</h3>
                    <div class="box-tools pull-right">
                        <button type="button" class="btn btn-box-tool" data-widget="collapse"><i
                                class="fa fa-minus"></i></button>
                    </div>
                </div>
                <!-- /.box-header -->
                <div class="box-body">
                    <form action="${request.contextPath}/app/search" method="post">
                        <div class="row col-sm-offset-1">
                            <div class="col-md-5">
                                <div class="form-group">
                                    <label>APP ID</label>
                                    <input type="text" class="form-control" name="appId"
                                           value="<#if req?exists >${req.appId}</#if>">
                                </div>
                                <!-- /.form-group -->
                                <div class="form-group">
                                    <label>项目名称</label>
                                    <input type="text" class="form-control" name="appName"
                                           value="<#if req?exists >${req.appName}</#if>">
                                </div>
                                <!-- /.form-group -->
                            </div>
                            <!-- /.col -->
                            <div class="col-md-5">
                                <div class="form-group">
                                    <label>项目状态</label>
                                    <select name="status" class="form-control select2" data-placeholder="Select a State"
                                            style="width: 100%;">
                                        <option <#if req?exists && req.status == "" >selected</#if> value="">全部</option>
                                        <option <#if req?exists && req.status == "Start" >selected</#if> value="Start">
                                            启用
                                        </option>
                                        <option <#if req?exists && req.status == "Stop" >selected</#if> value="Stop">
                                            停用
                                        </option>
                                    </select>
                                </div>
                                <!-- /.form-group -->
                            </div>
                            <!-- /.col -->
                        </div>
                        <div class="row col-sm-offset-4">
                            <div class="col-md-2">
                                <button type="submit" class="btn btn-block btn-primary">查询</button>
                            </div>
                            <div class="col-md-2">
                                <button id="addAppBtn" type="button" class="btn btn-block btn-primary">新应用</button>
                            </div>
                        </div>
                    </form>
                </div>
                <!-- /.box-body -->
            </div>
            <!-- /.box -->
        </section>
        <#if appList?exists>
            <section class="content">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="box">
                            <!-- /.box-header -->
                            <div class="box-body">
                                <table id="dataList" style="width:100%;table-layout:fixed;" class="display nowrap table table-bordered table-striped">
                                    <thead>
                                    <tr>
                                        <th>APP ID</th>
                                        <th>应用名</th>
                                        <th>访问权限</th>
                                        <th>服务类型</th>
                                        <th>应用描述</th>
                                        <th>负责人</th>
                                        <th>状态</th>
                                        <#--<th>创建时间</th>
                                        <th>更新时间</th>-->
                                        <th style="width: 20%">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                <#list appList as item>
                                <tr id="${item.id}">
                                    <td>${item.appId}</td>
                                    <td>${item.appName}</td>
                                    <td>
                                        <#if item.authType == "Public">公共应用</#if>
                                        <#if item.authType == "Private">私有应用</#if>
                                    </td>
                                    <td>
                                        <#if item.appType == "web">web应用</#if>
                                        <#if item.appType == "server">server应用</#if>
                                    </td>
                                    <td>${item.appDesc!''}</td>
                                    <td style="text-overflow:ellipsis;overflow:hidden;white-space:nowrap;" onclick="showText(5,this)">${item.leader}</td>
                                    <td>
                                        <#if item.status == "Start">启用</#if>
                                        <#if item.status == "Stop">停用</#if>
                                    </td>
                                    <#--<td>${item.createTime?string('yyyy-MM-dd HH:mm:ss')}</td>
                                    <td>${item.updateTime?string('yyyy-MM-dd HH:mm:ss')}</td>-->
                                    <td>
                                        <div class="col-sm-4">
                                            <#if item.status == "Stop">
                                                <button type="button" class="btn btn-block btn-xs btn-primary" onclick="changeStatus('${item.appId}',this)">启用</button>
                                            </#if>
                                            <#if item.status == "Start">
                                                <button type="button" class="btn btn-block btn-xs btn-danger" onclick="changeStatus('${item.appId}',this)">停用</button>
                                            </#if>
                                        </div>
                                        <div class="col-sm-4">
                                            <button type="button" class="btn btn-block btn-xs btn-warning" onclick="changeApp('${item.appId}')">编辑</button>
                                        </div>
                                        <div class="col-sm-4">
                                            <button type="button" class="btn btn-block btn-xs btn-danger" onclick="deleteApp('${item.appId}','${item.id}')">删除</button>
                                        </div>
                                    </td>
                                </tr>
                                </#list>
                                    </tbody>
                                </table>
                            </div>
                            <!-- /.box-body -->
                        </div>
                        <!-- /.box -->
                    </div>
                </div>
            </section>
        </#if>
    </div>
</div>

<@netCommon.commonScript />
<script src="${request.contextPath}/static/js/app.js"></script>
</body>
</html>